clear all
set more off
cd "[working directory]\Replication_files"
graph set window fontface "Times New Roman"
global control "age hhmale high_edu minor  c4 c5 famsize   poorrg"
global FE "_Icountyid_2 _Icountyid_3"
global graphopts_options "xtitle(Normalized base-year income per capita, size(normal))  xlabel(#7, labsize(normal)) ylabel(#5, labsize(normal)) legend(off)"
use Household_data_anonymized.dta, clear
	
	*** Generate county dummies
	xi: qui reg growth i.countyid
	
	
	do Define_bandwidth
	capture drop optimal_bd1
	
********************************************************************************
	*** First stage
********************************************************************************
	g optimal_bd1 = (runningrl<treated_optimal_bd & runningrl>-treated_optimal_bd)
	cmogram treated runningrl if optimal_bd1, cut(0) scatter line(0) lfitci lfitopts(level(95)) graphopts($graphopts_options ///
		ytitle(National Poverty Household, size(normal)))
	graph export ".\Output\Figure1.png", replace
	
	
********************************************************************************
	*** Income growth
********************************************************************************
	replace optimal_bd1 = (runningrl<growth_optimal_bd & runningrl>-growth_optimal_bd)
	cmogram growth runningrl if optimal_bd1, cut(0) scatter line(0) lfitci lfitopts(level(95)) graphopts($graphopts_options ///
		ytitle(Change in log income per capita 2013-18, size(normal))) ///
		controls($control $FE)
	graph export ".\Output\Figure2.png", replace

	
	
********************************************************************************
	*** Consistency score
********************************************************************************
	replace optimal_bd1 = (runningrl<ccei_optimal_bd & runningrl>-ccei_optimal_bd)
	cmogram ccei runningrl if optimal_bd1, cut(0) scatter line(0) lfitci lfitopts(level(95)) graphopts($graphopts_options ///
		ytitle(Critical cost efficiency index (CCEI), size(normal))) ///
		controls($control $FE)
	graph export ".\Output\Figure3a.png", replace
	
	
	replace optimal_bd1 = (runningrl<cceid_optimal_bd & runningrl>-cceid_optimal_bd)
	cmogram cceid runningrl if optimal_bd1, cut(0) scatter line(0) lfitci lfitopts(level(95)) graphopts($graphopts_options ///
		ytitle(CCEI>0.95, size(normal))) ///
		controls($control $FE)
	graph export ".\Output\Figure3b.png", replace

	
********************************************************************************
	*** Distributional preferences
********************************************************************************
	replace optimal_bd1 = (runningrl<slfsqw_optimal_bd & runningrl>-slfsqw_optimal_bd)
	cmogram slfsqw runningrl if optimal_bd1, cut(0) scatter line(0) lfitci lfitopts(level(95)) graphopts($graphopts_options ///
		ytitle(Selfishness score, size(normal))) ///
		controls($control $FE)
	graph export ".\Output\Figure4a1.png", replace
	
	replace optimal_bd1 = (runningrl<equsqw_optimal_bd & runningrl>-equsqw_optimal_bd)
	cmogram equsqw runningrl if optimal_bd1, cut(0) scatter line(0) lfitci lfitopts(level(95)) graphopts($graphopts_options ///
		ytitle(Equality score, size(normal))) ///
		controls($control $FE)
	graph export ".\Output\Figure4b1.png", replace
	
	replace optimal_bd1 = (runningrl<effsqw_optimal_bd & runningrl>-effsqw_optimal_bd)
	cmogram effsqw runningrl if optimal_bd1, cut(0) scatter line(0) lfitci lfitopts(level(95)) graphopts($graphopts_options ///
		ytitle(Efficiency score, size(normal))) ///
		controls($control $FE)
	graph export ".\Output\Figure4c1.png", replace
	
	
	replace optimal_bd1 = (runningrl<Sel_optimal_bd & runningrl>-Sel_optimal_bd)
	cmogram Sel runningrl if optimal_bd1, cut(0) scatter line(0) lfitci lfitopts(level(95)) graphopts($graphopts_options ///
		ytitle(Selfish=1, size(normal))) ///
		controls($control $FE)
	graph export ".\Output\Figure4a2.png", replace
	
	replace optimal_bd1 = (runningrl<Leo_optimal_bd & runningrl>-Leo_optimal_bd)
	cmogram Leo runningrl if optimal_bd1, cut(0) scatter line(0) lfitci lfitopts(level(95)) graphopts($graphopts_options ///
		ytitle(Equality focused=1, size(normal))) ///
		controls($control $FE)
	graph export ".\Output\Figure4b2.png", replace
	
	replace optimal_bd1 = (runningrl<Sub_optimal_bd & runningrl>-Sub_optimal_bd)
	cmogram Sub runningrl if optimal_bd1, cut(0) scatter line(0) lfitci lfitopts(level(95)) graphopts($graphopts_options ///
		ytitle(Efficiency focused=1, size(normal))) ///
		controls($control $FE)
	graph export ".\Output\Figure4c2.png", replace
	
	
